'''
Created on Apr 2, 2012

@author: Johnathon
'''
from Gates.ANDGate import AndGate
from LineValues import Zero, One, X
import Wire
import unittest
import util


class Test(unittest.TestCase):


    def setUp(self):
        self.in1 = Wire()
        self.in2 = Wire()
        self.output = Wire()
        self.gate = AndGate("Name", 1, [self.in1, self.in2], self.output)


    def tearDown(self):
        pass


    def testName(self):
        pass

    def testXLineValue(self):
        for val in util.VALUES:
            if val is not Zero:
                self.assertTrue(X.AND(val) is X)
    
    def testSimple(self):
        self.in1.driveValue(One)
        self.in2.driveValue(One)
        self.gate.evaluate()
        self.assertTrue(self.output.value is One)
        
    def test0Output(self):
        self.in1.driveValue(Zero)
        for x in util.VALUES:
            self.in2.driveValue(x)
            self.gate.evaluate()
            self.assertTrue(self.output.value is Zero)
        self.in2.driveValue(Zero)
        for x in util.VALUES:
            self.in1.driveValue(x)
            self.gate.evaluate()
            self.assertTrue(self.output.value is Zero)

if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    unittest.main()